Basic

Switch Case

Goto

Operators

if Statement

Nested if

While Loop

For Loop

Array

Patterns

Excersises


While Loop


while loop is a most basic loop in C programming. while loop has one control condition, and executes as long the condition is true. The condition of the loop is tested before the body of the loop is executed, hence it is called an entry-controlled loop.

Example : pgm.c

#include<stdio.h>
int main(){
    int i=1;
    while(i<=10){
        printf("\n%d",i);
        i++;
    }
    return 0;
}

Output:

1
2
3
4
5
6
7
8
9
10